package cn.jzq.kotoba.modules.designpattern.command.control;

/**
 * @author jzq
 * @date 2019/2/21 10:40
 */

public class SimpleRemoteControl {
    private Command slot;

    public void setCommand(Command command) {
        this.slot = command;
    }

    public void buttonWasPressed() {
        slot.execute();
    }

    public static void main(String[] args) {
        SimpleRemoteControl remoteControl = new SimpleRemoteControl();
        Light light = new Light();
        LightOnCommand lightOnCommand = new LightOnCommand(light);
        Door door = new Door();
        DoorOpenCommand doorOpenCommand = new DoorOpenCommand(door);
        remoteControl.setCommand(lightOnCommand);
        remoteControl.buttonWasPressed();
        remoteControl.setCommand(doorOpenCommand);
        remoteControl.buttonWasPressed();
    }
}
